<#include "/common/head.html"/> 
<table id="dg"></table>
<div id="tb" style="padding:2px 5px;">
      <!-- <a href="javascript:void(0)" class="easyui-linkbutton addBtn" iconCls="glyphicon-plus" plain="true" onclick="add()">添加规则</a> -->
    <input type="hidden" value="${shop.id!''}" id="id"></input>
	<input type="hidden" value="${shop.searchNumber!''}" id="searchNumber"></input>
	<input type="hidden" value="${shop.balance!''}" id="balance"></input>
	<input type="hidden" value="${shop.name!''}" id="name"></input>
	<input type="hidden" value="${shop.remarks!''}" id="shopSet_id">
	<a href="javascript:void(0)" class="easyui-linkbutton updateBtn" iconCls="glyphicon-pencil" plain="true" onclick="importrule()">导入规则</a>
	<a href="javascript:void(0)" class="easyui-linkbutton updateBtn" iconCls="glyphicon-pencil" plain="true" onclick="update()">修改分值</a>
   	<a href="javascript:void(0)" class="easyui-linkbutton addBtn" iconCls="glyphicon-remove" plain="true" onclick="delete1()">删除</a>
	<a href="javascript:void(0)" class="easyui-linkbutton addBtn" iconCls="glyphicon-remove" plain="true" onclick="back()">返回</a>
</div>
	
<script type="text/javascript">
var shopId=$("#id").val();
var searchNumber=$("#searchNumber").val();
var balance=$("#balance").val();
var name=$("#name").val();
var datagrid = $("#dg");
var dgOptions = {
        rownumbers:true,
    	fit:true,
    	border:false,
    	striped:true,
        rownumbers:true,
    	url:'detailList?id='+$("#id").val(),
    	method:'post',
    	toolbar:'#tb',
    	pageSize: 20,
    	pagination:true,
    	multiSort:true,
    	singleSelect:false,
//         queryParams: getInitParam(),
        columns: [[
				   {field:'ruleCode', title: '规则编号', width:100}
		           ,{field:'type',title: '规则类型', width:80}
				   ,{field:'description',title: '规则描述', width:280}
				   ,{field:'section', title: '规则区间', width:100}
				   ,{field:'store',title: '分值', width:80}
	           ]]
	};
$(function() {
	datagrid.datagrid(dgOptions);
});
		
function update() {
	var rowsSel = datagrid.datagrid("getSelections");
	if(rowsSel.length != 1) {
		showWarnMsg("请选择一条数据！");
		return;
	}
	var id = rowsSel[0].id;
	location.replace('updateStore?id='+id+"&name="+name+"&balance="+balance+"&searchNumber="+searchNumber+"&setId="+$("#shopSet_id").val());
}

function back() {
	location.replace('detailpageList?id='+shopId+"&name="+name+"&balance="+balance+"&searchNumber="+searchNumber+"&setId="+$("#shopSet_id").val());
}
//导入规则
function importrule() {
	location.replace('detailRule?id='+shopId+"&name="+name+"&balance="+balance+"&searchNumber="+searchNumber+"&setId="+$("#shopSet_id").val());
}

//删除
function delete1() {
	var rowsSel = datagrid.datagrid("getSelections");
	if(rowsSel.length != 1) {
		showWarnMsg("请选择一条数据！");
		return;
	}
	var id = rowsSel[0].id;
	confirmMsg("确认删除吗？", function() {
/* 		var bb="";
		for (var i = 0; i < rowsSel.length; i++) {
			var aa = rowsSel[i].positionid;
			bb = aa + "|" +bb;
		} */
		var id = rowsSel[0].id;
		$.post("delete", {id: id}, function(data) {
			var result = data.result;
			if(result=='success'){
				showMsg("删除成功！");
				datagrid.datagrid("reload");
			}else{
				showWarnMsg(result);
        		return;
			}
		});
	});
}

</script>
<#include "/common/dialogWindow.html"/>
<#include "/common/foot.html"/>